﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="NhapHang.aspx.cs" Inherits="NhapHang" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <div class="panel panel-success margin">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        Quản lý nhập hàng</h3>
                </div>
                <div class="panel-body">
                    <table width="100%">
                        <tr>
                            <td width="20%">
                                <span style="margin-left: 5px;">Số phiếu</span><br />
                                <asp:TextBox ID="txtSoPhieu" Enabled="false" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">Ngày nhập</span><br />
                                <asp:TextBox ID="txtNgayNhap" runat="server" AutoPostBack="true" 
                                    CssClass="form-control with98" ontextchanged="txtNgayNhap_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator1" runat="server"
                                    ControlToValidate="txtNgayNhap" ErrorMessage="Nhập ngày nhập" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>

                                <cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtNgayNhap"
                                Format="dd/MM/yyyy">
                            </cc1:CalendarExtender>
                            <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender12" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtNgayNhap" ValidChars="/-" />
                                
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">Giờ nhập</span><br />
                                <asp:TextBox ID="txtGioNhap" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">Trạm trộn</span><br />
                                <asp:DropDownList runat="server" 
                                    CssClass="form-control width98" ID="dlTramTron" DataValueField="IDs" DataTextField="TenTramTron" >
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator7" runat="server"
                                    ControlToValidate="dlTramTron" ErrorMessage="Chọn trạm trộn" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <span style="margin-left: 5px;">Đơn vị tính</span><br />
                                <asp:TextBox ID="txtTon" Visible="false" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <asp:TextBox ID="txtDVT" ToolTip="kg, m3, lít" runat="server" CssClass="form-control with98"></asp:TextBox>
                            </td>
                        </tr>
                         <tr>
                            <td width="20%">
                                <span style="margin-left: 5px;">Biển số
                                <asp:CheckBox ID="ckXeNha" runat="server" Text="Xe nhà" 
                                AutoPostBack="true" oncheckedchanged="dlBenChayCuoc_SelectedIndexChanged" />
                                <asp:CheckBox ID="ckQuaCan" Checked="true" runat="server" Text="Qua cân" 
                                AutoPostBack="true" oncheckedchanged="ckQuaCan_CheckedChanged" />
                                </span><br />
                                <asp:TextBox ID="txtBienSo" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <asp:DropDownList runat="server" Visible="false" 
                                    CssClass="form-control width98" ID="dlBienSo"
                                    DataValueField="IDs" AutoPostBack="true" DataTextField="DoiTuongChi" 
                                    onselectedindexchanged="dlBienSo_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">Bên chạy cước&nbsp;<asp:CheckBox ID="ckCuocVCVAT" runat="server" Text="VAT" /></span><br />
                                <asp:DropDownList runat="server" AutoPostBack="true" 
                                    CssClass="form-control width98" ID="dlBenChayCuoc"
                                    DataValueField="IDs" DataTextField="TenNCC" 
                                    onselectedindexchanged="dlBenChayCuoc_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator4" runat="server"
                                    ControlToValidate="dlBenChayCuoc" ErrorMessage="Chọn bên chạy cước" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">Lái xe</span><br />
                                <asp:TextBox ID="txtLaiXe" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <asp:DropDownList runat="server" Visible="false" CssClass="form-control width98" ID="dlLaiXe"
                                    DataValueField="IDs" AutoPostBack="true" DataTextField="HoTen" OnSelectedIndexChanged="dlLaiXe_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">Loại vật liệu</span><br />
                                <asp:DropDownList runat="server" AutoPostBack="true" CssClass="form-control width98" ID="dlLoaiVatLieu"
                                    DataValueField="IDs" DataTextField="TenLoaiVL" onselectedindexchanged="dlBenBan_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator2" runat="server"
                                    ControlToValidate="dlLoaiVatLieu" ErrorMessage="Chọn loại vật liệu" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <span style="margin-left: 5px;">Bên bán</span><br />
                                <asp:DropDownList runat="server" CssClass="form-control widthall" ID="dlBenBan"
                                    DataValueField="IDs" AutoPostBack="true" DataTextField="TenNCC" 
                                    onselectedindexchanged="dlBenBan_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator3" runat="server"
                                    ControlToValidate="dlBenBan" ErrorMessage="Chọn bên bán" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                            
                        </tr>
                        <tr>
                            <td width="20%">
                                <span style="margin-left: 5px;">TL tổng</span><br />
                                <asp:TextBox ID="txtTLTong" AutoPostBack="true" runat="server" 
                                    CssClass="form-control with98" ontextchanged="txtTLTong_TextChanged"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtTLTong" ValidChars=",.-" />
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">TL bì</span><br />
                                <asp:TextBox ID="txtTLBi" AutoPostBack="true" runat="server" 
                                    CssClass="form-control with98" ontextchanged="txtTLBi_TextChanged"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtTLBi" ValidChars=",.-" />
                                
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">TL hàng</span><br />
                                <asp:TextBox ID="txtTLHang" ReadOnly="true" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtTLHang" ValidChars=",.-" />
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">KL mua <asp:CheckBox ID="ckKLMuaVAT" Text="VAT" runat="server" />
                                </span><br />
                                <asp:TextBox ID="txtKLMua" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtKLMua" ValidChars=",.-" />
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator8" runat="server"
                                    ControlToValidate="txtKLMua" ErrorMessage="Nhập khối lượng mua" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <span style="margin-left: 5px;">KL thực tế</span><br />
                                <asp:TextBox ID="txtKLThucTe" runat="server" AutoPostBack="true" ontextchanged="txtTiLeQuiDoi_TextChanged" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtKLThucTe" ValidChars=",.-" />
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator9" runat="server"
                                    ControlToValidate="txtKLThucTe" ErrorMessage="Nhập khối lượng thực tế" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td width="20%">
                                <span style="margin-left: 5px;">Độ ẩm</span><br />
                                <asp:TextBox ID="txtDoAm" runat="server" CssClass="form-control with98" AutoPostBack="true"
                                    ontextchanged="txtDoAm_TextChanged"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtDoAm" ValidChars=",.-" />
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">Tỉ lệ qui đổi</span><br />
                                <asp:TextBox ID="txtTiLeQuiDoi" AutoPostBack="true" runat="server" 
                                    CssClass="form-control with98" ontextchanged="txtTiLeQuiDoi_TextChanged"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender7" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtTiLeQuiDoi" ValidChars=",.-" />
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator6" runat="server"
                                    ControlToValidate="txtTiLeQuiDoi" ErrorMessage="Nhập tỉ lệ qui đổi" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                                
                            </td>
                            <td width="20%">
                                <span style="margin-left: 5px;">TL sau qui đổi</span><br />
                                <asp:TextBox ID="txtKLSauQuiDoi" runat="server" CssClass="form-control with98"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" FilterType="Custom,Numbers"
                                TargetControlID="txtKLSauQuiDoi" ValidChars=",.-" />
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator5" runat="server"
                                    ControlToValidate="txtKLSauQuiDoi" ErrorMessage="Nhập trọng lượng sau qui đổi" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td colspan="2">
                                <span style="margin-left: 5px;">Ghi chú</span><br />
                                <asp:TextBox ID="txtGhiChu" runat="server" CssClass="form-control withall"></asp:TextBox>
                            </td>
                            
                        </tr>
                        
                        <tr>
                            <td colspan="5">
                                <asp:Button ID="btnSave" ValidationGroup="Them" runat="server" Style="margin-left: 5px;"
                                    Text="Lưu lại" CssClass="btn btn-primary" onclick="btnSave_Click" />
                                <asp:Button ID="btncapnhat" ValidationGroup="Them" runat="server" Text="Cập nhật" CssClass="btn btn-info"
                                     Visible="false" onclick="btncapnhat_Click" />
                                <asp:Button ID="btnCancel" runat="server" Text="Nhập mới" 
                                    CssClass="btn btn-warning" onclick="btnCancel_Click"
                                     />
                            </td>
                        </tr>
                    </table>
                    <asp:ValidationSummary ID="ValidationSummary1" HeaderText="Bạn phải nhập các trường sau:"
                        ShowMessageBox="true" ValidationGroup="Them" ShowSummary="false" EnableClientScript="true"
                        runat="server" />
                </div>
            </div>
            <div style="margin: 5px;">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <b>Danh sách nhập hàng</b>
                    </div>
                    <div>
                    <asp:DropDownList ID="dlThang" AutoPostBack="true" runat="server" Width="150px" 
                            CssClass="form-control" onselectedindexchanged="dlThang_SelectedIndexChanged">
                        </asp:DropDownList>
                        <asp:DropDownList ID="dlNam" runat="server" Width="140px" CssClass="form-control">
                        </asp:DropDownList>
                        <asp:TextBox ID="txtTuNgay" runat="server" AutoPostBack="true" OnTextChanged="dlThang_SelectedIndexChanged" placeholder="Từ ngày" Visible="true"  Width="100px" CssClass="form-control"></asp:TextBox>&nbsp;
                        <asp:TextBox ID="txtDenNgay" runat="server" placeholder="Đến ngày" OnTextChanged="dlThang_SelectedIndexChanged" AutoPostBack="true" Visible="true"
                             Width="100px" CssClass="form-control"></asp:TextBox>
                        <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtTuNgay"
                            Format="dd/MM/yyyy">
                        </cc1:CalendarExtender>
                        <cc1:CalendarExtender ID="CalendarExtender3" runat="server" TargetControlID="txtDenNgay"
                            Format="dd/MM/yyyy">
                        </cc1:CalendarExtender>
                        <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender9" runat="server" FilterType="Custom,Numbers"
                            TargetControlID="txtTuNgay" ValidChars="/-" />
                        <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender10" runat="server" FilterType="Custom,Numbers"
                            TargetControlID="txtDenNgay" ValidChars="/-" />
                        <asp:DropDownList ID="dlNhaCungCapLoc" ToolTip="Chọn bên bán" runat="server"  AutoPostBack="true"
                            DataValueField="IDs" Width="250px" CssClass="form-control"
                            DataTextField="TenNCC" 
                            onselectedindexchanged="dlNhaCungCapLoc_SelectedIndexChanged">
                        </asp:DropDownList>
                        <asp:DropDownList ID="dlLoaiVLLoc" ToolTip="Chọn loại vật liệu" runat="server" DataValueField="IDs" Width="200px" CssClass="form-control"
                            DataTextField="TenLoaiVL">
                        </asp:DropDownList>
                        <asp:DropDownList ID="dlBenChayCuocLoc" ToolTip="Chọn bên chạy cước" runat="server" DataValueField="IDs" Width="200px" CssClass="form-control"
                            DataTextField="TenNCC">
                        </asp:DropDownList>
                        <asp:Button ID="btnXem" CssClass="btn btn-warning" runat="server" Text="Tìm kiếm"
                            OnClick="btnXem_Click" />
                            <asp:HiddenField ID="hdTuNgay" runat="server" />
                            <asp:HiddenField ID="hdDenNgay" runat="server" />
                            
                    </div>
                    <div style="width: 100%; margin-top: 0px;" class="wrapper">
                        <asp:GridView ID="GV" runat="server" AutoGenerateColumns="false" BackColor="White"
                            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" EmptyDataText="Không có dữ liệu nào"
                            EnableModelValidation="True" ShowFooter="true" CssClass="form-control withall"
                            Width="99%" OnRowCommand="GV_RowCommand">
                            <Columns>
                                <asp:TemplateField HeaderText="Xóa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                    ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="lbXoa" runat="server" Width="20px" Height="20px" ImageUrl="~/img/delete-24.png"
                                            OnClientClick="return confirm('Bạn chắc chắn muốn xóa ?')" CommandArgument='<%#Eval("IDs")%>'
                                            Text="Xóa" CommandName="Del" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Sửa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                    ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="lbSua" runat="server" Width="15px" Height="15px" ImageUrl="~/img/edit.ico"
                                            CommandArgument='<%#Eval("IDs")%>' Text="Sửa" CommandName="Select" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="SoPhieu" ItemStyle-CssClass="padding" HeaderText="Số phiếu"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                    <asp:BoundField DataField="NgayNhap" ItemStyle-CssClass="padding" HeaderText="Ngày nhập"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                    <asp:BoundField DataField="TenLoaiVL" ItemStyle-CssClass="padding" HeaderText="Loại vật liệu"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:BoundField DataField="BenBan" ItemStyle-CssClass="padding" HeaderText="Bên bán"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:BoundField DataField="BenChayCuoc" ItemStyle-CssClass="padding" HeaderText="Bên chạy cước"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:BoundField DataField="BienSoID" ItemStyle-CssClass="padding" HeaderText="Biển số xe"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                    <asp:BoundField DataField="KLMua" ItemStyle-CssClass="padding" HeaderText="KL mua"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="KLThucTe" ItemStyle-CssClass="padding" HeaderText="KL thực tế"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="TLHang" ItemStyle-CssClass="padding" HeaderText="TL hàng" DataFormatString="{0:0,0}"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="KLSauQuiDoi" ItemStyle-CssClass="padding" HeaderText="TL sau qui đổi" DataFormatString="{0:0,0}"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="KLMuaVAT" ItemStyle-CssClass="padding" HeaderText="KL mua VAT"
                                    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                            </Columns>
                            <FooterStyle BackColor="White" ForeColor="#000066" Font-Bold="True" HorizontalAlign="Right" />
                            <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black" Height="30px" />
                            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                            <RowStyle BackColor="White" ForeColor="#000066" Height="30px" />
                            <SelectedRowStyle BackColor="Lavender" Font-Bold="false" />
                        </asp:GridView>
                    </div>
                    <div style="margin: 5px;">
                            <asp:Button ID="btnFirst" runat="server" Text="Đầu" CssClass="btn btn-primary" OnClick="btnFirst_Click" />
                            <asp:Button ID="btnPre" runat="server" Style="margin-left: 5px;" Text="Trước" CssClass="btn btn-primary"
                                OnClick="btnPre_Click" />
                            <asp:Button ID="btnNext" runat="server" Style="margin-left: 5px;" Text="Sau" CssClass="btn btn-warning"
                                OnClick="btnNext_Click" />
                        </div>
                </div>
                <asp:HiddenField ID="hdID" runat="server" />
                <asp:HiddenField ID="hdLaiXeID" runat="server" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

